/**************************************************************************** 
* 
* Copyright (c) 2023  C*Core -   All Rights Reserved  
* 
* THIS SOFTWARE IS DISTRIBUTED "AS IS," AND ALL WARRANTIES ARE DISCLAIMED, 
* INCLUDING MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
* 
* PROJECT     : CCFC2011BC           
* DESCRIPTION : CCFC2011BC eMIOS low level drivers code 
* HISTORY     : Initial version.
* @file     emios_lld.c
* @version  1.1
* @date     2023 - 02 - 20
* @brief    Initial version.
*
*****************************************************************************/
#include "siul_lld.h"
#include "icu_lld.h"
#include "emios_lld.h"

/*===========================================================================*/
/* Driver interrupt handlers.                                                */
/*===========================================================================*/
ICUDriver ICUD_0;
PWMDriver PWMD_0;
ICUDriver ICUD_1;
PWMDriver PWMD_1;
/*******************************************************************************
 * @brief      eMIOS0 Channels 0 and 1 interrupt handler.
 *             It is assumed that the various sources are only activated if the
 *             associated callback pointer is not equal to @p NULL in order to not
 *             perform an extra check in a potentially critical interrupt handler.
 * @param[in]  None
 * @param[out] None
 * @retval     None
 * @notapi
 *******************************************************************************/
static IRQ_HANDLER(EMIOS0_GFR_F0F1_HANDLER)
{
    IRQ_PROLOGUE();

    if ((ICUD_0.emiosp->CH[0].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[0].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[0].CCR.B.MODE == EMIOS_CCR_MODE_IPM)  ||
        (ICUD_0.emiosp->CH[1].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[1].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[1].CCR.B.MODE == EMIOS_CCR_MODE_IPM))
    {
        ICU_LLD_Serve_Interrupt(&ICUD_0, ICU_INTERRUPT_GROUP_0, 0);
    }
    else
    {
        PWM_LLD_Serve_Interrupt(&PWMD_0, 0);
    }

    IRQ_EPILOGUE();
}

/*******************************************************************************
 * @brief      IRQ_HANDLER
 * @param[in]  None
 * @param[out] None
 * @retval     None
 * @notapi
 *******************************************************************************/
static IRQ_HANDLER(EMIOS0_GFR_F2F3_HANDLER)
{
    IRQ_PROLOGUE();

    if ((ICUD_0.emiosp->CH[2].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[2].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[2].CCR.B.MODE == EMIOS_CCR_MODE_IPM)  ||
        (ICUD_0.emiosp->CH[3].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[3].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[3].CCR.B.MODE == EMIOS_CCR_MODE_IPM))
    {
        ICU_LLD_Serve_Interrupt(&ICUD_0, ICU_INTERRUPT_GROUP_1, 2);
    }
    else
    {
        PWM_LLD_Serve_Interrupt(&PWMD_0, 2);
    }

    IRQ_EPILOGUE();
}

/*******************************************************************************
 * @brief      IRQ_HANDLER
 * @param[in]  None
 * @param[out] None
 * @retval     None
 * @notapi
 *******************************************************************************/
static IRQ_HANDLER(EMIOS0_GFR_F4F5_HANDLER)
{
    IRQ_PROLOGUE();

    if ((ICUD_0.emiosp->CH[4].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[4].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[4].CCR.B.MODE == EMIOS_CCR_MODE_IPM)  ||
        (ICUD_0.emiosp->CH[5].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[5].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[5].CCR.B.MODE == EMIOS_CCR_MODE_IPM))
    {
        ICU_LLD_Serve_Interrupt(&ICUD_0, ICU_INTERRUPT_GROUP_2, 4);
    }
    else
    {
        PWM_LLD_Serve_Interrupt(&PWMD_0, 4);
    }

    IRQ_EPILOGUE();
}

/*******************************************************************************
 * @brief      IRQ_HANDLER
 * @param[in]  None
 * @param[out] None
 * @retval     None
 * @notapi
 *******************************************************************************/
static IRQ_HANDLER(EMIOS0_GFR_F6F7_HANDLER)
{
    IRQ_PROLOGUE();

    if ((ICUD_0.emiosp->CH[6].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[6].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[6].CCR.B.MODE == EMIOS_CCR_MODE_IPM)  ||
        (ICUD_0.emiosp->CH[7].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[7].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[7].CCR.B.MODE == EMIOS_CCR_MODE_IPM))
    {
        ICU_LLD_Serve_Interrupt(&ICUD_0, ICU_INTERRUPT_GROUP_3, 6);
    }
    else
    {
        PWM_LLD_Serve_Interrupt(&PWMD_0, 6);
    }

    IRQ_EPILOGUE();
}

/*******************************************************************************
 * @brief      IRQ_HANDLER
 * @param[in]  None
 * @param[out] None
 * @retval     None
 * @notapi
 *******************************************************************************/
static IRQ_HANDLER(EMIOS0_GFR_F8F9_HANDLER)
{
    IRQ_PROLOGUE();

    if ((ICUD_0.emiosp->CH[8].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[8].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[8].CCR.B.MODE == EMIOS_CCR_MODE_IPM)  ||
        (ICUD_0.emiosp->CH[9].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[9].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[9].CCR.B.MODE == EMIOS_CCR_MODE_IPM))
    {
        ICU_LLD_Serve_Interrupt(&ICUD_0, ICU_INTERRUPT_GROUP_4, 8);
    }
    else
    {
        PWM_LLD_Serve_Interrupt(&PWMD_0, 8);
    }

    IRQ_EPILOGUE();
}

/*******************************************************************************
 * @brief      IRQ_HANDLER
 * @param[in]  None
 * @param[out] None
 * @retval     None
 * @notapi
 *******************************************************************************/
static IRQ_HANDLER(EMIOS0_GFR_F10F11_HANDLER)
{
    IRQ_PROLOGUE();

    if ((ICUD_0.emiosp->CH[10].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[10].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[10].CCR.B.MODE == EMIOS_CCR_MODE_IPM)  ||
        (ICUD_0.emiosp->CH[11].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[11].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[11].CCR.B.MODE == EMIOS_CCR_MODE_IPM))
    {
        ICU_LLD_Serve_Interrupt(&ICUD_0, ICU_INTERRUPT_GROUP_5, 10);
    }
    else
    {
        PWM_LLD_Serve_Interrupt(&PWMD_0, 10);
    }

    IRQ_EPILOGUE();
}

/*******************************************************************************
 * @brief      IRQ_HANDLER
 * @param[in]  None
 * @param[out] None
 * @retval     None
 * @notapi
 *******************************************************************************/
static IRQ_HANDLER(EMIOS0_GFR_F12F13_HANDLER)
{
    IRQ_PROLOGUE();

    if ((ICUD_0.emiosp->CH[12].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[12].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[12].CCR.B.MODE == EMIOS_CCR_MODE_IPM)  ||
        (ICUD_0.emiosp->CH[13].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[13].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[13].CCR.B.MODE == EMIOS_CCR_MODE_IPM))
    {
        ICU_LLD_Serve_Interrupt(&ICUD_0, ICU_INTERRUPT_GROUP_6, 12);
    }
    else
    {
        PWM_LLD_Serve_Interrupt(&PWMD_0, 12);
    }

    IRQ_EPILOGUE();
}

/*******************************************************************************
 * @brief      IRQ_HANDLER
 * @param[in]  None
 * @param[out] None
 * @retval     None
 * @notapi
 *******************************************************************************/
static IRQ_HANDLER(EMIOS0_GFR_F14F15_HANDLER)
{
    IRQ_PROLOGUE();

    if ((ICUD_0.emiosp->CH[14].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[14].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[14].CCR.B.MODE == EMIOS_CCR_MODE_IPM)  ||
        (ICUD_0.emiosp->CH[15].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[15].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[15].CCR.B.MODE == EMIOS_CCR_MODE_IPM))
    {
        ICU_LLD_Serve_Interrupt(&ICUD_0, ICU_INTERRUPT_GROUP_7, 14);
    }
    else
    {
        PWM_LLD_Serve_Interrupt(&PWMD_0, 14);
    }

    IRQ_EPILOGUE();
}

/*******************************************************************************
 * @brief      IRQ_HANDLER
 * @param[in]  None
 * @param[out] None
 * @retval     None
 * @notapi
 *******************************************************************************/
static IRQ_HANDLER(EMIOS0_GFR_F16F17_HANDLER)
{
    IRQ_PROLOGUE();

    if ((ICUD_0.emiosp->CH[16].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[16].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[16].CCR.B.MODE == EMIOS_CCR_MODE_IPM)  ||
        (ICUD_0.emiosp->CH[17].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[17].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[17].CCR.B.MODE == EMIOS_CCR_MODE_IPM))
    {
        ICU_LLD_Serve_Interrupt(&ICUD_0, ICU_INTERRUPT_GROUP_8, 16);
    }
    else
    {
        PWM_LLD_Serve_Interrupt(&PWMD_0, 16);
    }

    IRQ_EPILOGUE();
}

/*******************************************************************************
 * @brief      IRQ_HANDLER
 * @param[in]  None
 * @param[out] None
 * @retval     None
 * @notapi
 *******************************************************************************/
static IRQ_HANDLER(EMIOS0_GFR_F18F19_HANDLER)
{
    IRQ_PROLOGUE();

    if ((ICUD_0.emiosp->CH[18].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[18].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[18].CCR.B.MODE == EMIOS_CCR_MODE_IPM)  ||
        (ICUD_0.emiosp->CH[19].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[19].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[19].CCR.B.MODE == EMIOS_CCR_MODE_IPM))
    {
        ICU_LLD_Serve_Interrupt(&ICUD_0, ICU_INTERRUPT_GROUP_9, 18);
    }
    else
    {
        PWM_LLD_Serve_Interrupt(&PWMD_0, 18);
    }

    IRQ_EPILOGUE();
}

/*******************************************************************************
 * @brief      IRQ_HANDLER
 * @param[in]  None
 * @param[out] None
 * @retval     None
 * @notapi
 *******************************************************************************/
static IRQ_HANDLER(EMIOS0_GFR_F20F21_HANDLER)
{
    IRQ_PROLOGUE();

    if ((ICUD_0.emiosp->CH[20].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[20].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[20].CCR.B.MODE == EMIOS_CCR_MODE_IPM)  ||
        (ICUD_0.emiosp->CH[21].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[21].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[21].CCR.B.MODE == EMIOS_CCR_MODE_IPM))
    {
        ICU_LLD_Serve_Interrupt(&ICUD_0, ICU_INTERRUPT_GROUP_10, 20);
    }
    else
    {
        PWM_LLD_Serve_Interrupt(&PWMD_0, 20);
    }

    IRQ_EPILOGUE();
}

/*******************************************************************************
 * @brief      IRQ_HANDLER
 * @param[in]  None
 * @param[out] None
 * @retval     None
 * @notapi
 *******************************************************************************/
static IRQ_HANDLER(EMIOS0_GFR_F22F23_HANDLER)
{
    IRQ_PROLOGUE();

    if ((ICUD_0.emiosp->CH[22].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[22].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[22].CCR.B.MODE == EMIOS_CCR_MODE_IPM)  ||
        (ICUD_0.emiosp->CH[23].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[23].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[23].CCR.B.MODE == EMIOS_CCR_MODE_IPM))
    {
        ICU_LLD_Serve_Interrupt(&ICUD_0, ICU_INTERRUPT_GROUP_11, 22);
    }
    else
    {
        PWM_LLD_Serve_Interrupt(&PWMD_0, 22);
    }

    IRQ_EPILOGUE();
}

/*******************************************************************************
 * @brief      IRQ_HANDLER
 * @param[in]  None
 * @param[out] None
 * @retval     None
 * @notapi
 *******************************************************************************/
static IRQ_HANDLER(EMIOS0_GFR_F24F25_HANDLER)
{
    IRQ_PROLOGUE();

    if ((ICUD_0.emiosp->CH[24].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[24].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[24].CCR.B.MODE == EMIOS_CCR_MODE_IPM)  ||
        (ICUD_0.emiosp->CH[25].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[25].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[25].CCR.B.MODE == EMIOS_CCR_MODE_IPM))
    {
        ICU_LLD_Serve_Interrupt(&ICUD_0, ICU_INTERRUPT_GROUP_12, 24);
    }
    else
    {
        PWM_LLD_Serve_Interrupt(&PWMD_0, 24);
    }

    IRQ_EPILOGUE();
}

/*******************************************************************************
 * @brief      IRQ_HANDLER
 * @param[in]  None
 * @param[out] None
 * @retval     None
 * @notapi
 *******************************************************************************/
static IRQ_HANDLER(EMIOS0_GFR_F26F27_HANDLER)
{
    IRQ_PROLOGUE();

    if ((ICUD_0.emiosp->CH[26].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[26].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[26].CCR.B.MODE == EMIOS_CCR_MODE_IPM)  ||
        (ICUD_0.emiosp->CH[27].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[27].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[27].CCR.B.MODE == EMIOS_CCR_MODE_IPM))
    {
        ICU_LLD_Serve_Interrupt(&ICUD_0, ICU_INTERRUPT_GROUP_13, 26);
    }
    else
    {
        PWM_LLD_Serve_Interrupt(&PWMD_0, 26);
    }

    IRQ_EPILOGUE();
}

/*******************************************************************************
 * @brief      IRQ_HANDLER
 * @param[in]  None
 * @param[out] None
 * @retval     None
 * @notapi
 *******************************************************************************/
static IRQ_HANDLER(EMIOS0_GFR_F28F29_HANDLER)
{
    IRQ_PROLOGUE();

    if ((ICUD_0.emiosp->CH[28].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[28].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[28].CCR.B.MODE == EMIOS_CCR_MODE_IPM)  ||
        (ICUD_0.emiosp->CH[29].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[29].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[29].CCR.B.MODE == EMIOS_CCR_MODE_IPM))
    {
        ICU_LLD_Serve_Interrupt(&ICUD_0, ICU_INTERRUPT_GROUP_14, 28);
    }
    else
    {
        PWM_LLD_Serve_Interrupt(&PWMD_0, 28);
    }

    IRQ_EPILOGUE();
}

/*******************************************************************************
 * @brief      IRQ_HANDLER
 * @param[in]  None
 * @param[out] None
 * @retval     None
 * @notapi
 *******************************************************************************/
static IRQ_HANDLER(EMIOS0_GFR_F30F31_HANDLER)
{
    IRQ_PROLOGUE();

    if ((ICUD_0.emiosp->CH[30].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[30].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[30].CCR.B.MODE == EMIOS_CCR_MODE_IPM)  ||
        (ICUD_0.emiosp->CH[31].CCR.B.MODE == EMIOS_CCR_MODE_SAIC) ||
        (ICUD_0.emiosp->CH[31].CCR.B.MODE == EMIOS_CCR_MODE_IPWM) ||
        (ICUD_0.emiosp->CH[31].CCR.B.MODE == EMIOS_CCR_MODE_IPM))
    {
        ICU_LLD_Serve_Interrupt(&ICUD_0, ICU_INTERRUPT_GROUP_15, 30);
    }
    else
    {
        PWM_LLD_Serve_Interrupt(&PWMD_0, 30);
    }

    IRQ_EPILOGUE();
}

/*******************************************************************************
 * @brief      ICU_LLD_Interrupt_Register
 * @param[in]  const ICUDriver * icudriver, uint8_t channel
 * @param[out] None
 * @retval     None
 * @notapi
 *******************************************************************************/
void ICU_LLD_Interrupt_Register(const ICUDriver * icudriver, uint8_t channel)
{
    if (icudriver->emiosp != &EMIOS_1)
    {
        switch (channel)
        {
            case 0:
            case 1:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F0F1_HANDLER, EMIOS0_GFR_F0F1_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            case 2:
            case 3:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F2F3_HANDLER, EMIOS0_GFR_F2F3_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            case 4:
            case 5:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F4F5_HANDLER, EMIOS0_GFR_F4F5_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            case 6:
            case 7:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F6F7_HANDLER, EMIOS0_GFR_F6F7_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            case 8:
            case 9:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F8F9_HANDLER, EMIOS0_GFR_F8F9_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            case 10:
            case 11:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F10F11_HANDLER, EMIOS0_GFR_F10F11_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            case 12:
            case 13:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F12F13_HANDLER, EMIOS0_GFR_F12F13_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            case 14:
            case 15:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F14F15_HANDLER, EMIOS0_GFR_F14F15_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            case 16:
            case 17:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F16F17_HANDLER, EMIOS0_GFR_F16F17_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            case 18:
            case 19:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F18F19_HANDLER, EMIOS0_GFR_F18F19_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            case 20:
            case 21:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F20F21_HANDLER, EMIOS0_GFR_F20F21_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            case 22:
            case 23:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F22F23_HANDLER, EMIOS0_GFR_F22F23_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            case 24:
            case 25:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F24F25_HANDLER, EMIOS0_GFR_F24F25_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            case 26:
            case 27:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F26F27_HANDLER, EMIOS0_GFR_F26F27_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            case 28:
            case 29:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F28F29_HANDLER, EMIOS0_GFR_F28F29_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            case 30:
            case 31:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F30F31_HANDLER, EMIOS0_GFR_F30F31_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            default:
                break;
        }
    }
}

/*******************************************************************************
 * @brief      PWM_LLD_Interrupt_Register
 * @param[in]  const PWMDriver * pwmdriver, uint8_t channel
 * @param[out] None
 * @retval     None
 * @notapi
 *******************************************************************************/
void PWM_LLD_Interrupt_Register(const PWMDriver * pwmdriver, uint8_t channel)
{
    if (pwmdriver->emiosp != &EMIOS_1)
    {
        switch (channel)
        {
            case 0:
            case 1:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F0F1_HANDLER, EMIOS0_GFR_F0F1_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            case 2:
            case 3:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F2F3_HANDLER, EMIOS0_GFR_F2F3_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            case 4:
            case 5:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F4F5_HANDLER, EMIOS0_GFR_F4F5_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            case 6:
            case 7:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F6F7_HANDLER, EMIOS0_GFR_F6F7_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            case 8:
            case 9:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F8F9_HANDLER, EMIOS0_GFR_F8F9_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            case 10:
            case 11:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F10F11_HANDLER, EMIOS0_GFR_F10F11_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            case 12:
            case 13:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F12F13_HANDLER, EMIOS0_GFR_F12F13_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            case 14:
            case 15:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F14F15_HANDLER, EMIOS0_GFR_F14F15_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            case 16:
            case 17:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F16F17_HANDLER, EMIOS0_GFR_F16F17_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            case 18:
            case 19:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F18F19_HANDLER, EMIOS0_GFR_F18F19_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            case 20:
            case 21:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F20F21_HANDLER, EMIOS0_GFR_F20F21_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            case 22:
            case 23:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F22F23_HANDLER, EMIOS0_GFR_F22F23_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            case 24:
            case 25:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F24F25_HANDLER, EMIOS0_GFR_F24F25_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            case 26:
            case 27:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F26F27_HANDLER, EMIOS0_GFR_F26F27_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            case 28:
            case 29:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F28F29_HANDLER, EMIOS0_GFR_F28F29_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            case 30:
            case 31:
                INTC_InstallINTCInterruptHandler(EMIOS0_GFR_F30F31_HANDLER, EMIOS0_GFR_F30F31_NUMBER, EMIOS0_GFR_F0F1_PRIORITY);
                break;
            default:
                break;
        }
    }
    /* Channel enables.*/
    pwmdriver->emiosp->UCDIS.R &= ~(1UL << channel);

    /* Clear pending IRQs (if any).*/
    pwmdriver->emiosp->CH[channel].CSR.R = EMIOSS_OVRC |
        EMIOSS_OVFLC | EMIOSS_FLAGC;

    /* Active interrupts.*/
    pwmdriver->emiosp->CH[channel].CCR.B.FEN = 1U;

    /* Channel disables.*/
    pwmdriver->emiosp->UCDIS.R |= (1UL << channel);
}

